<?php
namespace app\know\controller;

use cmf\controller\AdminBaseController;
use think\facade\Log;
use app\admin\model\UserModel;
use app\know\model\OpLogModel;

class AdminKnowBaseController extends AdminBaseController
{
    protected function getAdminUser()
    {
        $sessionAdminId = session('ADMIN_ID');
        return UserModel::where('id', $sessionAdminId)->find();
    }

    protected function uuid($prefix = '', $line = '-')
    {
        $chars = md5(uniqid(mt_rand(), true));
        $uuid = substr( $chars, 0, 8 ) . $line
            . substr ( $chars, 8, 4 ) . $line
            . substr ( $chars, 12, 4 ) . $line
            . substr ( $chars, 16, 4 ) . $line
            . substr ( $chars, 20, 12 );
        return $prefix . $uuid ;
    }

    protected function opLog($data)
    {
        OpLogModel::create($data);
        // $model->save($data);
    }

    protected function log($data)
    {
        Log::debug($data);
    }
	
	protected function htmlDecode($c)
    {
        return htmlspecialchars_decode(htmlspecialchars_decode($c));
    }
}
